package com.sky.controller.user;

import com.sky.entity.Setmeal;
import com.sky.entity.SetmealDish;
import com.sky.result.Result;
import com.sky.service.SetmealService;
import com.sky.vo.DishItemVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController("userSetmealController")
@RequestMapping("/user/setmeal")
@Api(tags = "用户端-套餐浏览接口")
@RequiredArgsConstructor
@Slf4j
public class SetmealController {
    private final SetmealService setmealService;

    /**
     * 获取分类下的所有套餐
     *
     * @param categoryId
     * @return
     */
    @GetMapping("/list")
    @ApiOperation(value = "获取分类下的所有套餐")
    @ApiImplicitParam(name = "categoryId", value = "分类id", required = true, dataType = "Long")
    public Result<List<Setmeal>> list(Long categoryId) {
        log.info("categoryId-{}", categoryId);
        return Result.success(setmealService.list(categoryId));
    }

    /**
     * 根据套餐id查询包含的菜品列表
     *
     * @param id
     * @return
     */
    @GetMapping("/dish/{id}")
    @ApiOperation(value = "根据套餐id查询包含的菜品列表")
    @ApiImplicitParam(name = "id", value = "套餐id", required = true, dataType = "Long")
    public Result<List<DishItemVO>> dishList(@PathVariable Long id) {
        log.info("id-{}", id);
        return Result.success(setmealService.dishList(id));
    }
}
